package com.mavenq.fly.business.controller;

import com.alibaba.fastjson.JSONObject;
import com.mavenq.fly.business.PersonService;
import com.mavenq.fly.business.entity.OperationLog;
import com.mavenq.fly.business.service.LogService;
import com.mavenq.fly.business.vo.Person;
import com.mavenq.fly.commons.exception.BusinessException;
import com.mavenq.fly.commons.resp.ResponseBuilder;
import com.mavenq.fly.commons.resp.ResponseObj;
import com.mavenq.fly.commons.tools.SpringBeanFactory;
import com.mavenq.fly.config.UploadProperties;
import com.mavenq.fly.listener.PushEvent;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationEvent;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@RestController
@RequestMapping("/log")
@Slf4j
public class LogController {

    @Autowired
    private LogService logService;


    @RequestMapping("/save")
    public ResponseObj saveLog(@RequestBody OperationLog operationLog)  {
        log.info("输入参数：operationLog={}", JSONObject.toJSON(operationLog));
        operationLog.setOperationTime(new Date());
        OperationLog operationLog1 = logService.saveLog(operationLog);
        log.warn("返回结果: operationLog={}", JSONObject.toJSON(operationLog1));
        return ResponseBuilder.buildSuccess(operationLog1);
    }


}
